
version 8.0 
log using pres_runoff.log, replace
 #delimit ;

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      pres_runoff.do                                  *;
*       Date:           5/18/05                                         *;
*       Author:         MRG                                             *;
*       Purpose:        Do-file to replicate results for AJPS version   *;
*                       of presidential candidates paper where          *;
*                       dependent variable is presidential candidates.  *;
*                       Tables 2 and 3.  Also does first part of        *;
*                       Afghanistan example.                            *;
*       Input File:     presidential_new.dta                            *;
*       Output File:    pres_runoff.log                                 *;
*       Data Output:    None                                            *;
*       Previous file:                                                  *;
*       Machine:        Office                                          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

set mem 10m;
set matsize 150;

use c:\ajps\presidential_new.dta;

*     ****************************************************************  *;
*                           Summary Statistics                          *;
*     ****************************************************************  *;

sum;

*     ****************************************************************  *;
*                    Relabel and Define Variables                       *;
*     ****************************************************************  *;

label var country  "countryname";
label var newdem "first election as new democracy";
label var countrynumber "countrynumber";
label var year "year";
label var regime "regime as of 31 December of given year 0=democracy 1=dictatorship";
label var regime_leg "regime type at time of legislative election 0 = democracy 1=dictatorship";
label var legelec "legislative election";
label var preselec "presidential election";
label var eighties "election in 1980s closest to 1985";
label var old "elections in countries that did not transition to democracy in 1990s";
label var nineties "elections in 1990s closest to 1995";
label var proximity1 "proximity - continuous";
label var proximity2 "proximity - dichotomous";
label var enpp "parliamentary parties - uncorrected";
label var enpp1 "parliamentary parties - corrected";
label var enep "electoral parties - uncorrected";
label var enep1 "electoral parties - corrected";
label var enpres "effective number of presidential candidates";
label var seats "assembly size";
label var districts "number of electoral districts";
label var avemag "average district magnitude";
label var medmag "median district magnitude";
label var upperseats "number of uppertier seats";
label var uppertier "percentage of uppertier seats";
label var eneg "effective number of ethnic groups  fearon";

describe;

sum preselec if pres_plurality==1;
sum preselec if pres_majority==1;
sum preselec if pres_qualmaj==1;
sum preselec if pres_stv==1;
sum preselec if pres_college==1;
sum preselec if pres_runoff==1;

*     ****************************************************************  *;
*       Would like to drop certain countries that do not fit.           *;
*       1. Drop Kiribati - not free entry of candidates                 *;
*       2. Drop elections that ultimately use an electoral college      *;
*       to determine who wins.  This means dropping Argentina 1946,     *;
*       1958, 1963, 1983, 1989, United States (all presidential         *;
*       elections), Finland 1950, 1956, 1962, 1968, 1978, 1982.         *;
*       3. Drop Ireland (all presidential elections) and Sri Lanka      *;
*       1994, 1999 since they use STV.                                  *;
*     ****************************************************************  *;

drop if countrynumber==163;
drop if countrynumber==65;
drop if countrynumber==113;
drop if countrynumber==96;
drop if countrynumber==66 & year==1946;
drop if countrynumber==66 & year==1958;
drop if countrynumber==66 & year==1963;
drop if countrynumber==66 & year==1983;
drop if countrynumber==66 & year==1989;
drop if countrynumber==106 & year==1950;
drop if countrynumber==106 & year==1956;
drop if countrynumber==106 & year==1962;
drop if countrynumber==106 & year==1968;
drop if countrynumber==106 & year==1978;
drop if countrynumber==106 & year==1982;

sum;

sum countrynumber if enpres>0 & enpres<200 & eneg>0 & eneg<200; 

sum countrynumber if enpres>0 & eneg>0 & eneg<300 & enpres<200 & pres_runoff==1;

sum countrynumber if enpres>0 & eneg>0 & eneg<300 & enpres<200 & pres_plurality==1;

sum enpres if enpres>0 & enpres<200 & eneg>0 & eneg<200;

sum eneg if enpres>0 & enpres<200 & eneg>0 & eneg<200;

*     ****************************************************************  *;
*       214 presidential elections left. 135 runoff, 79 plurality       *;
*       53 countries                                                    *;
*     ****************************************************************  *;

sum enpres if eighties==1;

sum enpres if nineties==1;

*     ****************************************************************  *;
*       21 countries had presidential elections in the 1980s.           *;
*       56 countries had presidential elections in the 1990s.           *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Let's see what the differences are between the cox data for     *;
*       1980s and the data that I collected.                            *;
*     ****************************************************************  *;

correlate enpres_cox enpres;

correlate eneth_cox eneg;

*     ****************************************************************  *;
*           The correlations are actually quite high i.e. 95-99%        *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*                   Create variables ready for regressions              *;
*     ****************************************************************  *;

gen eneg_runoff = eneg*pres_runoff;

*     ****************************************************************  *;
*                               1980s                                   *;
*     ****************************************************************  *;

regress enpres eneg pres_runoff  eneg_runoff if eighties==1, robust;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;

*     ****************************************************************  *;
*           What is the effect of eneg as runoff changes in the 1980s?  *;
*           When runoff is 0, then the effect of eneg is 0.11 (0.12)    *;
*           When runoff is 1, then the effect of eneg is 0.65 (0.31)    *;
*           When runoff is 1, eneg is significant at the 90% level and  *;
*           very close to 95%.                                          *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*                               1990s                                   *;
*     ****************************************************************  *;

regress enpres eneg pres_runoff eneg_runoff if nineties==1, robust;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;


*     ****************************************************************  *;
*       Effect of eneg in plurality systems is -0.25 (0.12).            *;
*       Effect of eneg in runoff systems is 0.19 (0.09).                *;
*       Thus, eneg is significant at 90% level when runoff=1            *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Now move on to pooled analyses                                  *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*                            Full Sample                                *;
*     ****************************************************************  *;

regress enpres eneg pres_runoff eneg_runoff, robust cluster(country);

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;

*     ****************************************************************  *;
*       Effect of eneg in plurality systems is -0.08 (0.07).            *;
*       Effect of eneg in runoff systems is 0.34 (0.11).                *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*                       Established Democracies                         *;
*     ****************************************************************  *;

regress enpres eneg pres_runoff eneg_runoff if old==1, robust cluster(country);

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;


*     ****************************************************************  *;
*       Effect of eneg in plurality systems is -0.06 (0.13).            *;
*       Effect of eneg in runoff systems is 0.60 (0.20).                *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*    Presidential Regimes: Not shown in Tables 2 or 3                   *;
*     ****************************************************************  *;

regress enpres eneg pres_runoff eneg_runoff if institution==3, robust cluster(country);

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;

*     ****************************************************************  *;
*       Effect of eneg in plurality systems is -0.10 (0.08).            *;
*       Effect of eneg in runoff systems is 0.49 (0.20).                *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*                       Established Presidential Regimes                *;
*     ****************************************************************  *;

regress enpres eneg pres_runoff eneg_runoff if institution==3 & old==1, robust cluster(country);

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;

*     ****************************************************************  *;
*       Effect of eneg in plurality systems is -0.08 (0.13).            *;
*       Effect of eneg in runoff systems is 0.69 (0.21).                *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Afghanistan example                                             *;
*     ****************************************************************  *;

regress enpres pres_runoff eneg eneg_runoff if old==1, robust cluster(country);

generate JH=((_n-1)/10);

replace JH=. if _n>60;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

gen conb=b1+b3*JH if _n<60;
set more off;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<60; 
set more off;

gen a=1.96*conse; 
gen top=conb+a; 
gen bottom=conb-a;
set textsize 100;

graph twoway  line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5 6, labsize(3.5)) 
            ylabel(-8 -6 -4 -2 0 2 4 6 8 10 , labsize(3.5))
            yscale(noline)
            xscale(noline)
            legend(off)
        yline(0, lcolor(black)) yline(-8 -6 -4 -2 2 4 6 8 10, lcolor(white))  
            xtitle(Effective Number of Ethnic Groups, size(4)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Runoff Procedure", size(4))
        scheme(s2mono) graphregion(fcolor(white));
        
*     ****************************************************************  *;
*       Runoff system is statistically significant if the effective     *;
*       number of ethnic groups is greater than 1.9. Afghanistan has    *;
*       4.01 effective ethnic groups.                                   *;
*     ****************************************************************  *;
        
gen afghan= b1+b3*4.01;

display afghan;

gen afghanse = sqrt(varb1+varb3*4.01^2+2*covb1b3*4.01);

display afghanse;

gen afghanci_upper=afghan+ afghanse*1.96;

display afghanci_upper;

gen afghanci_lower=afghan-afghanse*1.96;

display afghanci_lower;

*     ****************************************************************  *;
*       Shifting to a plurality system would reduce the effective       *;
*       number of presidential candidates by 1.77 [0.79, 2.75].         *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*     ****************************************************************  *;
*                                   THE END                             *;
*     ****************************************************************  *;
*     ****************************************************************  *;



exit;
